<?php
class Server {
  public static function send_enquiry($orm, $sys, $inst, $is_iframe) {
    
    $rslt = $orm->get('pb_ecom_admin', NULL, NULL, NULL, NULL, NULL)->d;
    if (count($rslt) > 0) {
      $req = json_decode(Utils::get_param('req', '[]'));
      require_once '../3rd_party/phpMailer/class.phpmailer.php';
      $mailer = new PHPMailer();
      $mailer->IsSMTP();
      $mailer->Host = SMTP_HOST;
      $mailer->CharSet = "UTF-8";
      
      $content = '';
      
      $mailer->SMTPAuth = true;
      $mailer->Username = SMTP_USER_ATDN;
      $mailer->Password = SMTP_PASS_ATDN;
      $mailer->From = $rslt[0]->email;
      $mailer->FromName = $rslt[0]->shop_name;
      
      $mailer->Body = "<div><b>Contact</b></div><div>$req->contact</div><div>&nbsp;</div><div><b>Enquiry</b></div><div>" . nl2br($req->content) . '</div>';
      $mailer->Subject = $req->product;
      $mailer->isHTML(true);
      $mailer->AddAddress($rslt[0]->email, '');
      $mailer->Send();
    }
  }
  
  public static function update_cart($orm, $sys, $inst, $is_iframe) {
    $req = json_decode(Utils::get_param('req', '[]'));
    $_SESSION['cart'] = json_encode($req);
  }
}
?>